next up previous contents index
Next: The Case statement Up: Statements controlling program flow. Previous: Statements controlling program flow.

Assignments

In addition to the standard Pascal assignment operator (:=), Free Pascal supports some c-style constructions. All available constructs are listed in table (1.5).

  

Assignment Result
a += b Adds b to a, and stores the result in a.
a -= b Substracts b from a, and stores the result in a.
a *= b Multiplies a with b, and stores the result in a.
a /= b Divides a through b, and stores the result in a.
Table 1.5: Allowed C constructs in Free Pascal

For these connstructs to work, you should specify the -Sc command-line switch.

Remark: These constructions are just for typing convenience, they don't generate different code.

Free Pascal also supports typed assignments. This means that an assignment statement has a definite type, and hence can be assigned to another variable. The type of the assignment a:=b is the type of a (or, in this case, of b), and this can be assigned to another variable : c:=a:=b;. To summarize: the construct

 a:=b:=c;
results in both a and b being assign the value of c, which may be an expression.

For this construct to be allowed, it is necessary to specify the -Sa4 switch on the command line.



Michael Van Canneyt
Tue Mar 31 16:48:49 CEST 1998